<template>
  <div class="out-bound-agent-page">
    <div class="search-wrapper">
      <super-search :search-form="searchForm" :search-item-config="searchItemList" @search="searchHandle"></super-search>
    </div>
    <div class="content-wrapper">
      <super-table
        :height="tableHeight"
        ref="tableRef"
        v-model:page="searchForm.pageNum"
        v-model:limit="searchForm.pageSize"
        :loading="loading"
        :data="tableData"
        :total="searchForm.total"
        :column="tableColumn"
        @change-page="getData"
      >
        <template #tool>
          <a-button type="primary" @click="addHandle">新增</a-button>
        </template>
        <template #status="{ row }">
          <a-tag v-if="row.status === 1" color="#87d068"> 启用 </a-tag>
          <a-tag v-if="row.status === 0" color="#cd201f"> 停用 </a-tag>
        </template>
        <template #action="{ row }">
          <a-button type="link" :danger="row.status === 1" @click="changeStatusHandle(row)">{{ row.status === 0 ? "启用" : "停用" }}</a-button>
          <a-button type="link" @click="editHandle(row)">编辑</a-button>
        </template>
      </super-table>
    </div>
    <!-- 抽屉 -->
    <a-drawer v-model:visible="drawerOpts.visible" :title="drawerOpts.title" :maskClosable="false" :closable="true" :width="drawerOpts.width" placement="right">
      <component
        v-model:visible="drawerOpts.visible"
        :is="drawerOpts.component"
        :logId="drawerOpts.passData?.id"
        sysModule="WAREHOUSE_CHANNEL"
        :type="drawerOpts.type"
        :pass-data="drawerOpts.passData"
        @submit="drawerSubmitHandle"
      ></component>
    </a-drawer>
  </div>
</template>
<script lang="ts">
import AddOutBoundAgent from "./components/addOutBoundAgent/index.vue";
export default {
  name: "OutBoundAgent",
  components: {
    AddOutBoundAgent
  }
};
</script>
<script lang="ts" setup>
import { tableColumn, searchItemList } from "./data";
import InitHook from "./composables/initHook";
import OperationHook from "./composables/operationHook";
import TableHeightHook from "@/hook/tableHeightHook";
import ModalHook from "@/hook/modalHook";
import { onMounted } from "vue";
const { tableHeight, loading } = TableHeightHook(50);
const { searchForm, tableData, drawerOpts } = InitHook();
const { searchHandle, getData, addHandle, editHandle, changeStatusHandle } = OperationHook({ searchForm, tableData, drawerOpts, loading });
const { drawerSubmitHandle } = ModalHook({
  drawerOpts,
  callBack: getData
});
onMounted(() => {
  getData();
});
</script>
<style lang="stylus" scoped></style>
